# from typing import NewType
from django.db import models
from DjangoUeditor.models import UEditorField # 导入另一个应用的模块
import django.utils.timezone as timezone

# Create your models here.

class MyNew(models.Model):
    NEWS_CHOICES = (
        ('企业要闻','企业要闻'),
        ('行业新闻','行业新闻'),
        ('通知公告','通知公告'),
    )
    title = models.CharField(max_length=50,verbose_name='新闻标题')
    description = UEditorField(u'内容',
                        default = '',
                        width= 1000,
                        height= 300,
                        imagePath='news/images/',
                        filePath='news/files/' )
    # NewType尽然是关键字;N大写； 其实很好奇，他把元组写成一个竖直的形式，有什么快捷的方式，我写了前面有空格的痕迹
    newType = models.CharField(choices=NEWS_CHOICES,
                                max_length=50,
                                verbose_name='新闻类型')

    # (models.E015) 'ordering' refers to the nonexistent field 'publishDate'.
    #publishDate我之前写成了publishData，他这里咋报错了，难道这个命名也要统一;是下方的class Meta:中使用了publishDate
    publishDate = models.DateTimeField(max_length=20,default=timezone.now,verbose_name='发布时间')
    views = models.PositiveIntegerField('浏览量',default=0)

    # 为首页展报服务 之前路径写错了，缩略图就没有显示出来
    photo = models.ImageField(upload_to='news/',
                              blank=True,
                              null=True,
                              verbose_name='展报')
# 上面没有同步
# Migrations for 'contactApp':
# contactApp\migrations\0006_auto_20211117_1633.py
# - Alter field birth on resume
# '''


    def __str__(self):
        return self.title

    class Meta:
        ordering = ['-publishDate']
        verbose_name = "新闻"
        verbose_name_plural = verbose_name

   